$import("com.joypard.platform.organization.org.OrgView");
$import("com.joypard.platform.organization.org.OrgDI");
$import("com.joypard.platform.organization.post.PostView");
$import("com.joypard.platform.organization.job.JobView");
$import("com.joypard.platform.organization.org.UserView");

/**
 * 定义组织机构视图
 */
K.defView("com.joypard.platform.organization.OrganizationView", {
	organizationCtrl : null, // 构造参数

	/**
	 * 权限配置
	 */
	purviewConfig : {
		view : "platform.organization"
	},

	/**
	 * 构造方法
	 * 
	 * @param organizationCtrl
	 */
	OrganizationView : function(organizationCtrl) {
		this.organizationCtrl = organizationCtrl;
		this.orgView = OrgView.instance(this);
		this.postView = PostView.instance(this);
		this.jobView = JobView.instance(this);
		this.userView = UserView.instance(this);
	},

	getOrganizationCtrl : function() {
		return this.organizationCtrl;
	},

	render : function() {
		this.orgTreePanel = this.orgView.createOrgTreePanel();
		this.orgEditPanel = this.orgView.createOrgEditPanel();
		this.attachTabPanel = this.createAttachTabPanel();

		var options = {};
		options.items = [];
		options.items.push(this.orgTreePanel);
		options.items.push(this.orgEditPanel);
		options.items.push(this.attachTabPanel);

		this.mainPanel = new K.Ext.MainPanel(options);

		 var root = this.orgTreePanel.getRootNode();
		if (root) {
			root.select();
			root.expand();
		}
	},

	/**
	 * 创建附加标签页面板,包括岗位信息、职位信息、用户信息 <br>
	 * region:east
	 */
	createAttachTabPanel : function() {
		var options = {
			title : "标签页",
			region : "east",
			margins : "2 2 3 0",
			width : "43%"
		};
		this.attachTabPanel = new K.Ext.TabPanel(options);

		if (PostView.purview()) {
			this.attachTabPanel.add(this.postView.createPostPanel());
		}
		if (JobView.purview()) {
			this.attachTabPanel.add(this.jobView.createJobPanel());
		}
		if (UserView.purview()) {
			this.attachTabPanel.add(this.userView.createUserPanel());
		}

		this.attachTabPanel.activate(0);
		return this.attachTabPanel;
	}
});